package tools.clustering;

import java.util.ArrayList;

public class LinkageCluster<T extends Link> {

	private ArrayList<T> links;
	private ArrayList<String> data;
	private String name;
	
	public LinkageCluster(String name){
		links= new ArrayList<T>();
		data= new ArrayList<String>();
		this.name=name;
	}
	
	public LinkageCluster(){
		this("");
	}
	
	
	public void addLink(T l){
		links.add(l);
		if(!data.contains(l.getSource())){
			data.add(l.getSource());
		}
		if(!data.contains(l.getTarget())){
			data.add(l.getTarget());
		}
	}
	
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ArrayList<T> getLinks() {
		return links;
	}

	public ArrayList<String> getData() {
		return data;
	}
	
	public int size(){
		return data.size();
	}
	
	public void add(LinkageCluster<T> b){
		this.data.addAll(b.getData());
		this.links.addAll(b.getLinks());
	}
	
	public String toString(){
		return "LinkageCluster with "+data.size()+" data and "+links.size()+" links";
	}
}
